from datetime import datetime

is_leap_year = lambda y: (y % 4 == 0 and y % 100 != 0) or y % 400 == 0


def get_days(year, month):
    days = {
        1: 31, 2: 28, 3: 31, 4: 30, 5: 31, 6: 30,
        7: 31, 8: 31, 9: 30, 10: 31, 11: 30, 12: 31
    }
    if month == 2 and is_leap_year(year):
        return 29
    else:
        return days[month]


def gap_between_dates(date_a, date_b):
    ay, am, ad = date_a
    by, bm, bd = date_b

    # sum1: days passed in year a
    sum1 = 0
    for i in range(1, am):
        sum1 += get_days(ay, i)
    sum1 += ad

    # sum2: days passed in year b
    sum2 = 0
    for i in range(1, bm):
        sum2 += get_days(by, i)
    sum2 += bd

    # two dates are in the same year
    if ay == by: return abs(sum2 - sum1)
    else:
        # swap if date a is later than date b
        if ay > by:
            ay, by = by, ay
            sum1, sum2 = sum2, sum1

        sum0 = 0

        # days of the whole years *between* ay and by
        for i in range(ay + 1, by):
            sum0 += 366 if is_leap_year(i) else 365

        # days left in year a
        sum0 += (365 + (1 if is_leap_year(ay) else 0) - sum1)
        # days passed in year b
        sum0 += sum2

        return sum0


birthday = (1999, 2, 1)
today = datetime.now()
today = (today.year, today.month, today.day)

print(today, "-", birthday, "=", gap_between_dates(birthday, today))
